package com.example.textviewactivity.Fragment;


import android.os.Bundle;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;

import com.example.textviewactivity.LoginSuccessActivity;
import com.example.textviewactivity.R;
import com.example.textviewactivity.pojo.User;

/**
 * A simple {@link Fragment} subclass.
 */
public class UserFragment extends Fragment {
    private String like="";
    private static final String TAG = "UserFragment";
    public UserFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_user, container, false);
        TextView tv=view.findViewById(R.id.user);
        LoginSuccessActivity  activity = (LoginSuccessActivity) getActivity();
        User user = activity.send();
        String[] hobby = user.getHobby();
        for (int i = 0; i < hobby.length; i++) {
            if (hobby[i]!=null){
                like+=hobby[i]+",";
            }
        }
        like=like.substring(0,like.length()-1);
        tv.setText("用户名:"+user.getName()+"\n手机号:"+user.getPhone()+"\n爱好:"+like+"\n性别:"+user.getSex());
        return view;
    }

}
